<template>
<!-- v-bind="$attrs" -->

<!--  <a-input :value="data"   :disabled="props.isAdd" placeholder="请选择"/>-->
  <div v-if="!isAdd">
    <a @click="openFn" v-if="!data">请选择</a>
    <div v-else>{{data}}</div>
  </div>

  <SelectOrderModal @register="register" @success="handleSuccess" :mode="props.mode" :isAdd="izAdd"></SelectOrderModal>
</template>

<script lang="ts" setup>
import SelectOrderModal from './SelectOrderModal.vue';
import { useDrawer } from '@/components/Drawer';

import {ref,computed} from "vue";
import {useMessage} from "@/hooks/web/useMessage";
import { useUserStore } from '@/store/modules/user';
const userStore = useUserStore();
import { useAttrs } from '@vben/hooks';
const attrs = useAttrs();
const data=computed(()=>attrs.value.value);

defineOptions({ name: 'SelectOrderIndex' });
const props = defineProps({
  mode: { type: String,default:"single" },
  isAdd: {type:Boolean,default:false},
  selectOrderNo:{type:Array}
}
);

const izAdd=computed(()=>props.isAdd);

// , 'update:value'

const emit = defineEmits([ 'change',"onSubmitFn"]);
const [register, { openDrawer,closeDrawer }] = useDrawer();
const { createMessage } = useMessage();

const options=ref([])

function openFn(e) {
  // console.log("---props.selectOrderNo",props.selectOrderNo)
  let json={};

  json={
    type:1,
    data: data.value,
    selectOrderNo:props.selectOrderNo,
  }
  if(e){
    if(e.title){
      json.title=e.title;
    }
     if(e.selectOrderNo){
     //  console.log("--e.selectOrderNo:",e.selectOrderNo)
       json.selectOrderNo=e.selectOrderNo
     }
  }
  openDrawer(true, json)
}
function handleSuccess(obj) {
  // let obj=list[0];
  // emit("change",obj);
  // emit("onChange",obj);
  emit("onSubmitFn",obj);
  // props.onSubmitFn(obj)

}

defineExpose({openFn})

</script>

<style lang="less" scoped>
.my-table-list {
  border: 1px solid #e8eaec;
  table {
    width: 100%;
    text-align: center;
    border-spacing: 0;
  }
  tr {
    //height: 30px;
    &:hover {
      background-color: #f5f7fa;
    }
  }
  th {
    //height: 40px;
    background-color: #f8f8f9;
    position: sticky;
    top: 0;
  }
  th,
  td {
    border-bottom: 1px solid #e8eaec;
    border-right: 1px solid #e8eaec;
  }
}

</style>
